<script>
	import {
		getTheme
	} from './api/api.js';
	import {
		useAppStore
	} from '@/stores/app'

	export default {
		globalData: {
			spread: 0,
			code: 0,
			isLogin: false,
			userInfo: {},
			MyMenus: [],
			windowHeight: 0,
			navHeight: 0,
			navH: 0,
			height: 0,
			id: 0,
			isIframe: false,
			theme: 'theme3',
			statusBarHeight: 0,
			tabBar: [
				'/pages/index/index',
				'/pages/goods_cate/index',
				'/pages/order_addcart/order_addcart',
				'/pages/user/index'
			],
			menuButtonInfo: {
				width: 0,
				height: 0,
				right: 0,
				top: 0,
				bottom: 0,
				left: 0
			}
		},
		onLaunch: async function(option) {
			const appStore = useAppStore()
			let that = this;
			// 主题变色
			await getTheme().then(resP => {
				appStore.SET_THEME(`theme${Number(resP.data.value)}`)
				that.globalData.theme = `theme${Number(resP.data.value)}`
				that.$Cache.set('theme', that.globalData.theme);
				console.log('theme', that.globalData.theme)
				// #ifdef H5
				window.document.documentElement.setAttribute('data-theme', that.globalData.theme);
				// #endif
			})

			uni.getSystemInfo({
				success: function(res) {
					that.globalData.height = res.windowHeight;
				}
			});

			// #ifdef MP-WEIXIN
			// 获取胶囊按钮信息
			this.menuButtonInfo = uni.getMenuButtonBoundingClientRect()
			// #endif
			// 获取导航高度；
			uni.getSystemInfo({
				success: function(res) {
					appStore.navHeight = res.statusBarHeight * (750 / res.windowWidth) + 91;
					appStore.statusBarHeight = res.statusBarHeight;

				}
			});

			// #ifdef APP-PLUS
			// 用来  微信支付回调回来跳转到钱包页面，实现重新刷新
			// uni.getSystemInfo({
			// 	success: function(res) { // 防止 andorid 系统点击通知栏的IM消息跳到钱包的情况
			// 		if (res.platform == 'ios') {
			// 			plus.globalEvent.addEventListener('newintent', (e) => {
			// 				var args = plus.runtime.arguments;
			// 				if (args) {
			// 					uni.redirectTo({
			// 						//关闭当前的webview,在跳进钱包实现重新刷新
			// 						url: "/pages/huojian/wallet/wallet"
			// 					})
			// 				}
			// 			});
			// 		}
			// 	}
			// });
			// #endif

		},
		onShow() {
			this.$util.setTabBar(this)
		},
	}
</script>
<style lang="scss">
	@import url("@/plugin/animate/animate.min.css");
	@import './static/css/base.scss';
	@import './static/iconfont/iconfont-old.css';
	// @import './static/iconfont/iconfont.css';
	@import './static/css/style.scss';

	// * {
	// 	box-sizing: border-box
	// }
	/* 条件编译，仅在H5平台生效 */
	// #ifdef H5
	body::-webkit-scrollbar,
	html::-webkit-scrollbar {
		display: none;
	}

	// #endif
	view {
		box-sizing: border-box;
	}

	.bg-color-red {
		background-color: #E93323;
	}

	.syspadding {
		padding-top: var(--status-bar-height);
	}

	.flex {
		display: flex;
	}

	.uni-scroll-view::-webkit-scrollbar {
		/* 隐藏滚动条，但依旧具备可以滚动的功能 */
		display: none
	}

	::-webkit-scrollbar {
		width: 0;
		height: 0;
		color: transparent;
	}
</style>